<template>
  <div class="app-container">
    <Ht-search-form
      v-show="showSearch"
      :advOptions="[]"
      :dictMap="dictMapAsync"
      :formOptions="formOptions"
      :outputQueryParams="queryParams"
      :queryParams="queryParams"
      :labelWidth="100"
    ></Ht-search-form>

    <ht-table
      ref="dataTable"
      :dictMap="dictMap"
      :multi-select="false"
      :opButtonList="opButtonList"
      :queryParams="queryParams"
      :reqConfig="regConfig"
      :showSerialNumber="false"
      :tableBindColumns="tableBindColumns"
    >
      <template v-slot:operate>
        <el-table-column align="left" fixed="right" label="操作" width="50">
          <template slot-scope="scope">
            <ht-button-group
              :buttonList="[
                {
                  label: '明细',
                  doFunc: () => {
                    handleAction('detail', scope.row);
                  },
                },
              ]"
            />
          </template>
        </el-table-column>
      </template>
    </ht-table>

    <!-- 添加或修改弹出框 -->
    <el-dialog
      :close-on-click-modal="false"
      :title="title"
      center
      :visible.sync="open"
      v-if="open"
      append-to-body
      width="1024px"
    >
      <el-form ref="detailForm" :disabled="true" :model="detailForm" label-width="140px">
        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>业务退回申请明细信息</span>
          </div>
          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="交易流水号" prop="id">
                <el-input v-model="detailForm.id" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="退回类型" prop="backType">
                <el-select style="width: 100%" v-model="detailForm.backType" placeholder="退回类型">
                  <el-option
                    v-for="dict in dictMap.RETURNTYPECODE"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="报文标识号" prop="pkgid">
                <el-input v-model="detailForm.pkgid" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="来往标识" prop="drct">
                <el-select style="width: 100%" v-model="detailForm.drct" placeholder="来往标识">
                  <el-option
                    v-for="dict in dictMap.DRCTCODE"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="内部机构号" prop="brno">
                <el-select style="width: 100%" v-model="detailForm.brno" placeholder="内部机构号">
                  <el-option
                    v-for="dict in dictMap['Cnaps2Dict.CP2_BRNO']"
                    :key="dict.value"
                    :label="`${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="交易渠道" prop="source">
                <el-select style="width: 100%" v-model="detailForm.source" placeholder="柜面交易">
                  <el-option
                    v-for="dict in dictMap.TXN_SOURCE"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="系统编号" prop="sysCode">
                <el-select style="width: 100%" v-model="detailForm.sysCode" placeholder="系统编号">
                  <el-option
                    v-for="dict in dictMap.SYS_CODE_310_312"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="工作日期" prop="workdate">
                <el-date-picker v-model="detailForm.workdate" style="width: 100%" type="date" value-format="yyyyMMdd" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="CPG日期" prop="vdate">
                <el-date-picker v-model="detailForm.vdate" style="width: 100%" type="date" value-format="yyyyMMdd" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="申请参与机构" prop="indirectSender">
                <el-input v-model="detailForm.indirectSender" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="申请参与机构名称" prop="indirectSenderName">
                <el-input v-model="detailForm.indirectSenderName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="应答参与机构" prop="indirectRcver">
                <el-input v-model="detailForm.indirectRcver" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="应答参与机构名称" prop="indirectRcverName">
                <el-input v-model="detailForm.indirectRcverName" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原报文类型" prop="oriPkgtype">
                <el-select
                  v-model="detailForm.oriPkgtype + '-' + detailForm.oriPkgtypeDesc"
                  placeholder="原报文类型"
                  style="width: 100%"
                ></el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="原报文标识号" prop="oriPkgid">
                <el-input v-model="detailForm.oriPkgid" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="原交易流水号/批次号" prop="reqOriId">
                <el-input v-model="detailForm.reqOriId" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="通讯状态" prop="status">
                <el-select style="width: 100%" v-model="detailForm.status" placeholder="通讯状态">
                  <el-option
                    v-for="dict in dictMap.PKG_STATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="业务状态" prop="txnStatus">
                <el-select style="width: 100%" v-model="detailForm.txnStatus" placeholder="业务状态">
                  <el-option
                    v-for="dict in dictMap.TXN_STATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="中心状态" prop="procStatus">
                <el-select style="width: 100%" v-model="detailForm.procStatus" placeholder="中心状态">
                  <el-option
                    v-for="dict in dictMap.PROCESSSTATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="申请录入操作员" prop="reqMdTlrno">
                <el-input v-model="detailForm.reqMdTlrno" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="申请录入时间" prop="reqMdTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.reqMdTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="申请审核操作员" prop="reqAudTlrno">
                <el-input v-model="detailForm.reqAudTlrno" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="申请审核时间" prop="reqAudTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.reqAudTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="申请发送时间" prop="reqSndTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.reqSndTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="申请接收时间" prop="reqRcvTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.reqRcvTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="24">
              <el-form-item label="附言" prop="reqRemarks">
                <el-input type="textarea" v-model="detailForm.reqRemarks" />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>

        <el-card class="form-card txnInfo-card">
          <div slot="header" class="label-header-msg">
            <span>业务退回应答明细信息</span>
          </div>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="交易流水号" prop="rspId">
                <el-input v-model="detailForm.rspId" />
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="退回类型" prop="backType">
                <el-select style="width: 100%" v-model="detailForm.backType" placeholder="退回类型">
                  <el-option
                    v-for="dict in dictMap.RETURNTYPECODE"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="报文标识号" prop="rspPkgId">
                <el-input v-model="detailForm.rspPkgId" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="退回应答结果" prop="backResult">
                <el-select style="width: 100%" v-model="detailForm.backResult" placeholder="退回应答结果">
                  <el-option
                    v-for="dict in dictMap.RET_ANSWER_RP00"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="24">
              <el-form-item label="附言" prop="rspRemarks">
                <el-input type="textarea" v-model="detailForm.rspRemarks" />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="通讯状态" prop="rspComStatus">
                <el-select style="width: 100%" v-model="detailForm.rspComStatus" placeholder="通讯状态">
                  <el-option
                    v-for="dict in dictMap.PKG_STATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="业务状态" prop="rspTxnStatus">
                <el-select style="width: 100%" v-model="detailForm.rspTxnStatus" placeholder="业务状态">
                  <el-option
                    v-for="dict in dictMap.TXN_STATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="中心状态" prop="rspProcStatus">
                <el-select style="width: 100%" v-model="detailForm.rspProcStatus" placeholder="中心状态">
                  <el-option
                    v-for="dict in dictMap.PROCESSSTATUS"
                    :key="dict.value"
                    :label="`${dict.value}-${dict.text}`"
                    :value="dict.value"
                  ></el-option>
                </el-select>
              </el-form-item>
            </el-col>

            <el-col :span="12">
              <el-form-item label="通用报文处理码" prop="comProcCode">
                <el-select
                  style="width: 100%"
                  v-model="
                    detailForm.comProcCode === null || detailForm.comProcCode === undefined
                      ? ''
                      : detailForm.comProcCode + '-' + detailForm.comProcCodeDesc
                  "
                  placeholder="通用报文处理码"
                ></el-select>
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="应答录入操作员" prop="rspMdTlrno">
                <el-input v-model="detailForm.rspMdTlrno" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="应答录入时间" prop="rspMdTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.rspMdTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="应答审核操作员" prop="rspAudTlrno">
                <el-input v-model="detailForm.rspAudTlrno" />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="应答审核时间" prop="rspAudTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.rspAudTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>

          <el-row type="flex">
            <el-col :span="12">
              <el-form-item label="应答发送时间" prop="rspSndTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.rspSndTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
            <el-col :span="12">
              <el-form-item label="应答接收时间" prop="rspRcvTime">
                <el-date-picker
                  style="width: 100%"
                  v-model="detailForm.rspRcvTime"
                  value-format="yyyyMMddHHmmss"
                  type="datetime"
                />
              </el-form-item>
            </el-col>
          </el-row>
        </el-card>
      </el-form>

      <div slot="footer" align="center" class="dialog-footer">
        <el-button type="primary" @click="cancel">关 闭</el-button>
      </div>
    </el-dialog>
  </div>
</template>

<script>
import { ccmsBusinessReturnResponsQueryDetail, apiUrlConfigResponseQuery } from "@/api/cnaps/ccms/319";
import { listPageMixin } from "@/libs/listPageMixin";
import { mapGetters } from "vuex";
export default {
  name: "CcmsBusinessReturnResponseQuery",
  mixins: [listPageMixin],
  components: {},
  computed: {
    ...mapGetters(["globalBusData"]),
  },
  created() {
    this.$set(this.queryParams, "brno", this.globalBusData.brno);
  },
  watch: {
    globalBusData: {
      handler(val) {
        this.$set(this.queryParams, "brno", val.brno);
      },
      deep: true,
      immediate: true,
    },
  },
  data() {
    return {
      // 查询参数
      queryParams: {
        id2: undefined,
        brno: undefined,
        cpgdate: undefined,
        cpgdate2: undefined,
        workdate: undefined,
        workdate2: undefined,
        drct: undefined,
        oriPkgid: undefined,
        indirectSender: undefined,
        indirectRcver: undefined,
      },

      // 搜索
      formOptions: [],
      //
      searchFormDictList: [
        "SYS_CODE_310_312",
        "RETURNTYPECODE",
        "PKG_STATUS",
        "DRCTCODE",
        "TXN_SOURCE",
        "PROCESSSTATUS",
        "TXN_STATUS",
        "RET_ANSWER_RP00",
        "Cnaps2Dict.CP2_BRNO",
      ],
      // 列信息
      regConfig: apiUrlConfigResponseQuery,

      tableBindColumns: [
        {
          prop: "brno",
          label: "内部机构号",
          dictCode: "Cnaps2Dict.CP2_BRNO",
        },
        {
          prop: "id",
          align: "center",
          label: "交易流水号",
          width: "200",
        },
        {
          prop: "sysCode",
          align: "center",
          label: "系统编号",
          dictCode: "SYS_CODE_310_312",
          width: "160",
        },
        {
          prop: "vdate",
          align: "center",
          label: "CPG日期",
          type: "date",
        },
        {
          prop: "workdate",
          align: "center",
          label: "工作日期",
          type: "date",
        },
        {
          prop: "oriPkgid",
          align: "center",
          label: "原报文标识号",
          width: "160",
        },
        {
          prop: "indirectSender",
          align: "center",
          label: "申请参与机构号",
          width: "160",
        },
        {
          prop: "indirectRcver",
          align: "center",
          label: "应答参与机构号",
          width: "160",
        },
        {
          prop: "drct",
          align: "center",
          label: "来往标识",
          dictCode: "DRCTCODE",
        },
        {
          prop: "backType",
          align: "center",
          label: "退回类型",
          dictCode: "RETURNTYPECODE",
          width: "160",
        },
        {
          prop: "status",
          align: "center",
          label: "通讯状态",
          dictCode: "PKG_STATUS",
        },
      ],
      dictMapAsync: {},
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      // 表单参数
      detailForm: {
        pkgNo: undefined,
        pkgNoDesc: undefined,
      },
      totalRecord: 0,
      totalPage: 0,
      needCount: 0,

      rules: {},
    };
  },
  mounted() {
    const formOptions = [
      // 普通搜索

      {
        type: "input",
        prop: "id2",
        defaultAttr: {
          size: "small",
          label: "交易流水号",
          placeholder: "请输入交易流水号",
        },
      },

      {
        type: "search-dept-tree",
        prop: "brno",
        defaultAttr: {
          radio: false,
          linkParentChoose: false,
          label: "分行选择",
          placeholder: "请选择分行",
        },
      },
      {
        type: "dates",
        nameObj: {
          startTimeName: "cpgdate",
          endTimeName: "cpgdate2",
        },
        defaultAttr: {
          size: "small",
          label: "CPG日期",
          placeholder: ["请输入CPG开始日期", "请输入CPG结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "dates",
        nameObj: {
          startTimeName: "workdate",
          endTimeName: "workdate2",
        },
        defaultAttr: {
          size: "small",
          label: "工作日期",
          placeholder: ["请输入工作开始日期", "请输入工作结束日期"],
          format: "yyyy-MM-dd",
          valueFormat: "yyyyMMdd",
        },
      },

      {
        type: "dict",
        dict: "DRCTCODE",
        prop: "drct",
        defaultAttr: {
          size: "small",
          label: "来往标识",
          placeholder: "请输入来往标识",
        },
      },

      {
        type: "input",
        prop: "oriPkgid",
        defaultAttr: {
          size: "small",
          label: "原报文标识号",
          placeholder: "请输入原报文标识号",
        },
      },

      {
        type: "input",
        prop: "indirectSender",
        defaultAttr: {
          size: "small",
          label: "申请参与机构号",
          placeholder: "请输入申请参与机构号",
        },
      },

      {
        type: "input",
        prop: "indirectRcver",
        defaultAttr: {
          size: "small",
          label: "应答参与机构号",
          placeholder: "请输入应答参与机构号",
        },
      },
    ];
    this.formOptions = formOptions;
    this.dictMapAsync = this.getDictMap();
  },
  methods: {
    /***
     * 按钮操作汇总
     */
    /***
     * 按钮操作汇总
     */
    handleAction(type, row = {}) {
      switch (type) {
        case "detail":
          this.handleDetail(row);
          break;
      }
    },

    // 关闭按钮
    cancel() {
      this.open = false;
    },

    /** 详情按钮操作 */
    handleDetail(row) {
      this.title = "业务退回应答查询明细";
      ccmsBusinessReturnResponsQueryDetail(row).then((response) => {
        this.detailForm = response.result;
        this.open = true;
      });
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
